package cn.javabb.controller;

import cn.javabb.service.CacheFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("/pan")
public class PanController {

    @Autowired
    CacheFileService cacheFileService;

    @GetMapping("/index")
    public String indexPage(){
        return "index";
    }

    @ResponseBody
    @PostMapping("/read")
    public Object readMenu(@RequestParam String menuName,@RequestParam Integer level ){
        Map<String,Object> map = new HashMap<String,Object>();
         String menuTxt = cacheFileService.readMenu(menuName,level);
         map.put("success",true);
         map.put("data",menuTxt);
        return map;
    }
}
